import React from "react";

class Demo extends React.Component {
  constructor(props) {
    super(props);
    // 让函数的this指向class的实例
    this.handleClick = this.handleClick.bind(this);
  }

  handleClick() {
    alert("哈哈哈哈哈哈");
  }

  render() {
    return (
      <div>
        <h4>绑定事件1</h4>
        <button onClick={this.handleClick}>click</button>
      </div>
    );
  }
}

export default Demo;
